1. Field of the Invention
The present invention pertains to the field of high speed digital data processors and more particularly, to a method of instruction implementation useful for operating system development.
2. Background Information
An operating system is a collection of programs that controls the execution of other programs in a computer system. Operating system programs reside in processor memory where they coordinate, among other things, such tasks as I/O operations and the execution of background tasks and application programs on the system. Operating systems free the application programmer from hardware anomalies by, in effect, hiding the hardware behind a well-behaved and documented interface. And they improve the efficiency of execution of a computer system by managing memory and controlling when a program can execute. As such the performance of the operating system is critical for achieving optimal system performance.
Since operating systems perform these critical functions of program and memory control, processors have evolved with powerful privileged instructions which can be used to affect the execution of the machine. Typical instructions are those used for I/O control, interrupt handling and masking and program control. Privileged instructions are typically constrained to execute in a privileged instruction mode accessible only to operating systems. This is done to protect systems from catastrophic failure due to incorrectly written application programs.
In the Cray Y-MP manufactured by the Assignee of the present invention, there are two modes of instruction execution: monitor mode and user mode. Privileged instructions run only in monitor mode. If a privileged instruction issues while the processor is not in monitor mode, it is treated as a no-operation instruction.
The operating system of the typical Cray Y-MP computer system manages execution of application programs through the use of exchange sequences, fetch sequences and issue sequences. Exchange sequences occur at initialization or when a program is started. An exchange sequence moves sets of basic parameters called exchange packages. Parameters currently residing in the operating registers of a processor are moved to memory and, simultaneously, different parameters are loaded to the operating registers.
The Cray Y-MP is a multitasking system. That is, it supports the execution of more than one program in a processor at a time. It also is a multiprocessing system. Therefore a program begun in one processor may be swapped to memory and continued later in a different processor. To facilitate this, each exchange package contains information that is used to coordinate the transition from one program to another. Exchange package contents describe the state of the processor at the time that a program is started or swapped to memory (exchanged). This information includes the contents of control registers, pending interrupts, current vector length and memory addressing constraints. It also includes the logical address of the processor that performed the exchange sequence. These are the basic parameters necessary to provide continuity when a program stops and restarts.
The development of an operating system is a complicated and time-consuming process which typically revolves around many iterations of software releases. The difficulty of the task is compounded by the need to test the system in privileged instruction mode in order to ascertain the function of the privileged instructions. Since an operating system running in privileged instruction mode is free of many of the constraints invoked to protect other software, operating systems must be debugged separate from application code. Then the operating system must be placed into a realistic environment in which it can be tested performing its control tasks.
This problem is compounded in the case of new hardware platforms. In the development of new operating systems on new hardware platforms, there is a great deal of uncertainty as to whether the hardware, operating system or application code is the source of a problem.
In prior art systems, special instructions have been provided that ease the task of debugging software. In microprocessors such as the 68000 family by Motorola, a facility is included for "tracing" following each instruction. When "tracing" is enabled, an exception is forced after each instruction is executed. Thus a debugging program can monitor the execution of the program under test.
The 68000 family also features trap instructions. The TRAP instruction always forces an exception and is useful for implementing system calls for user programs. Other instructions can force trap exceptions on abnormal conditions encountered during instruction execution (such as a division operation with a divisor of zero).
Although instructions like a TRAP instruction and facilities like trace make debugging of application code much easier, they are less useful in the development of operating systems. TRAP instructions can be used to detect error conditions or to cause an unconditional swap to the operating system. But they are of limited use in program code executing in privileged mode. Facilities such as trace create a large amount of overhead that can lead to uncharacteristic code execution and may cause one to miss errors in code interactions. This is especially critical in areas of system control such as I/O.
It is clear that there is a need for a method of developing operating system code that will promote rapid and accurate development of new operating systems. What is needed is a privileged instruction that can be executed to a limited extent in user mode without increasing the danger of system instability.